#include <stdio.h>
// 利用标准输入输出流来实现字符串的逐个输入输出
int main()
{
  int length, num, arr[length], index = 0, x = -1, flag = 1;
  for (int i = 1; flag != 0; i++)
  {
    printf("第一次运行需要先输入定义数组元素的个数，请输入:'0'\n");
    printf("输入数组数据请输入:'1'\n");
    printf("输出数组数据请输入:'2'\n");
    printf("退出程序请输入:'3'\n");
    scanf("%d", &x);
    for (int j = 0; j == 0; j++)
    {
      switch (x)
      {
      case 0:
        printf("请输入要数组元素的个数：\n");
        scanf("%d", &length);
        j += 1;
      case 1:
        printf("请输入数组的第%d个值:\n", i);
        scanf("%d", &num);
        arr[index] = num;
        index++;
        j += 1;
        flag = 1;
        break;
      case 2:
        printf("\n------------\n");
        printf("数组元素如下:\n");
        for (int k = 0; k < length; k++)
        {
          printf("%d ", arr[k]);
        }
        printf("\n------------\n");
        j += 1;
        break;
      case 3:
        printf("程序结束！\n");
        flag = 0;
      }
    }
  }
  return 0;
}